package com.teamcenter.rac.massupdate.ui.grid.layers;

import ca.odell.glazedlists.SortedList;
import com.teamcenter.rac.massupdate.ui.grid.ColumnAccessor;
import com.teamcenter.rac.massupdate.ui.grid.GridModel;
import com.teamcenter.rac.massupdate.ui.grid.IGridRow;
import net.sourceforge.nattable.config.IConfigRegistry;
import net.sourceforge.nattable.extension.glazedlists.GlazedListsSortModel;
import net.sourceforge.nattable.grid.data.DefaultColumnHeaderDataProvider;
import net.sourceforge.nattable.grid.layer.ColumnHeaderLayer;
import net.sourceforge.nattable.grid.layer.DefaultColumnHeaderDataLayer;
import net.sourceforge.nattable.layer.AbstractLayerTransform;
import net.sourceforge.nattable.layer.cell.ColumnOverrideLabelAccumulator;
import net.sourceforge.nattable.sort.SortHeaderLayer;
@SuppressWarnings({"rawtypes","unchecked"})
public class MassUpdateColumnHeaderLayerStack<T extends IGridRow> extends AbstractLayerTransform {
	private final DefaultColumnHeaderDataProvider m_columnHeaderDataProvider;
	private final DefaultColumnHeaderDataLayer m_columnHeaderDataLayer;
	private final SortHeaderLayer<T> m_sortHeaderLayer;
	private final ColumnOverrideLabelAccumulator m_columnOverrideLabelAccumulator;
	private final ColumnHeaderLayer m_columnHeaderLayer;

	public MassUpdateColumnHeaderLayerStack(GridModel paramGridModel,
			MassUpdateBodyLayerStack paramMassUpdateBodyLayerStack, SortedList<T> paramSortedList,
			IConfigRegistry paramIConfigRegistry) {
		ColumnAccessor localColumnAccessor = new ColumnAccessor(paramGridModel.getColumns());
		this.m_columnHeaderDataProvider = new DefaultColumnHeaderDataProvider(paramGridModel.getPropertyNames(),
				paramGridModel.getPropertyToLabelMap());
		this.m_columnHeaderDataLayer = new DefaultColumnHeaderDataLayer(this.m_columnHeaderDataProvider);
		this.m_columnHeaderLayer = new ColumnHeaderLayer(this.m_columnHeaderDataLayer, paramMassUpdateBodyLayerStack,
				paramMassUpdateBodyLayerStack.getSelectionLayer());
		this.m_sortHeaderLayer = new SortHeaderLayer(this.m_columnHeaderLayer, new GlazedListsSortModel(paramSortedList,
				localColumnAccessor, paramIConfigRegistry, this.m_columnHeaderDataLayer), false);
		this.m_columnOverrideLabelAccumulator = new ColumnOverrideLabelAccumulator(this.m_columnHeaderDataLayer);
		this.m_columnHeaderDataLayer.setConfigLabelAccumulator(this.m_columnOverrideLabelAccumulator);
		setUnderlyingLayer(this.m_sortHeaderLayer);
	}

	public DefaultColumnHeaderDataProvider getDataProvider() {
		return this.m_columnHeaderDataProvider;
	}

	public DefaultColumnHeaderDataLayer getDataLayer() {
		return this.m_columnHeaderDataLayer;
	}

	public SortHeaderLayer getSortHeaderLayer() {
		return this.m_sortHeaderLayer;
	}

	public ColumnOverrideLabelAccumulator getColumnOverrideLabelAccumulator() {
		return this.m_columnOverrideLabelAccumulator;
	}

	public ColumnHeaderLayer getColumnHeaderLayer() {
		return this.m_columnHeaderLayer;
	}
}
